package com.example.jmm.c2_thread.test;

public class ThreadStopDemo3 implements Runnable{
    @Override
    public void run() {
        for(int i = 1; i <= 5000 ; i++){

            try {
                Thread.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
                Thread.currentThread().interrupt();
            }
            if(Thread.currentThread().isInterrupted()){
                break;
            }
            System.out.println(i);
        }
    }
    public static void main(String[] args) {
        Thread t = new Thread(new ThreadStopDemo3());
        t.start();
        try {
            Thread.sleep(5);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        t.interrupt();
    }
}
